﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>测试服务器状态</title>
    <style type="text/css">
        * { font-size: 12px; }
        .iis { background-color: #eee; }
        .db { background-color: #ddd; }
    </style>
    <script src="http://img1.c2cedu.com/Scripts/jquery/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function getDate() {
            var d, s, t;
            d = new Date();
            s = d.getFullYear().toString(10).slice(-2) + "-";
            t = d.getMonth() + 1;
            s += (t > 9 ? "" : "0") + t + "-";
            t = d.getDate();
            s += (t > 9 ? "" : "0") + t + " ";
            t = d.getHours();
            s += (t > 9 ? "" : "0") + t + ":";
            t = d.getMinutes();
            s += (t > 9 ? "" : "0") + t + ":";
            t = d.getSeconds();
            s += (t > 9 ? "" : "0") + t;
            return s;
        }

        function testIIS(name, url) {
            $.ajax({
                type: "GET",
                dataType: "jsonp",
                cache: false,
                url: url,
                jsonp: "jsonpcallback",
                beforeSend: function (data) {
                    $("#iis" + name).html("<font color=red>Fail</font>");
                    $("#db" + name).html("<font color=red>Fail</font>");
                    $("#server" + name).html(data.Server);
                    $("#time" + name).html(getDate());
                },
                error: function (data) {
                },
                success: function (data) {
                    $("#server" + name).html(data.Server);
                    $("#iis" + name).html("<font color=green>" + data.IISMessage + "</font>");
                    $("#db" + name).html("<font color=green>" + data.DBMessage + "</font>");
                    $("#time" + name).html(getDate());
                }
            })
        }
        // 测试服务器1
        function test1() {
            testIIS(1, "http://test.eee114.com/test/testiis");
            setTimeout("test1()", 5000);
        }

        // 调用测试方法
        $(function () {
            test1();
        });

        
       
    </script>
</head>
<body>
    <fieldset>
        <legend>测试服务器状态</legend>
        <table cellpadding="5" cellspacing="0" border="1">
            <thead>
                <tr>
                    <td>
                        服务器IP
                    </td>
                    <td bgcolor="#eee">
                        IIS状态
                    </td>
                    <td bgcolor="#ddd">
                        数据库状态
                    </td>
                    <td>
                        检测时间
                    </td>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td id="server1">
                    </td>
                    <td class="iis" id="iis1">
                    </td>
                    <td class="db" id="db1">
                    </td>
                    <td id="time1">
                    </td>
                </tr>
            </tbody>
        </table>
    </fieldset>
</body>
</html>
